<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../base.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,factory-scalable=no" name="viewport">
</head>

<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
<section class="content-header">
    <h1>
        系统管理
        <small>用户管理</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="all-admin-index.html"><i class="fa fa-dashboard"></i> 首页</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">用户列表</h3>
        </div>
        <div class="box-body">
            <div class="table-box">
                <div class="pull-left">
                    <div class="form-group form-inline">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default" title="添加" onclick='location.href="${pageContext.request.contextPath}/pages/user/user-add.jsp"'>
                                <i class="fa fa-file-o"></i> 添加
                            </button>
                            <button type="button" class="btn btn-default" title="删除" onclick="deleteuser()">
                                <i class="fa fa-file-o"></i> 删除
                            </button>
                        </div>
                    </div>
                </div>
                <form action="/user" method="get">
                <div class="box-tools pull-right">
                    <div class="has-feedback">
                        <input type="text" name="username" class="form-control input-sm" placeholder="用户名搜索">
                        <input type="submit" value="搜索">
                        <span class="glyphicon glyphicon-search form-control-feedback"></span>
                    </div>
                </div>
                </form>
                <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                    <thead>
                    <tr>
                        <th class="sorting">选择</th>
                        <th class="sorting">患者ID</th>
                        <th class="sorting">患者姓名</th>
                        <th class="sorting">性别</th>
                        <th class="sorting">嘱咐</th>
                        <th class="sorting">部门</th>
                    </tr>
                    </thead>
                    <tbody>
                   <c:forEach items="${list}" var="Patient">
                       <tr>
                           <td><input type="radio" name="rdo" value="${Patient.id}"></td>
                           <td>${Patient.id}</td>
                           <td>${Patient.username}</td>
                           <td>${Patient.sex}</td>
                           <td>${Patient.enjoin}</td>
                           <td>${Patient.departments.depaname}</td>
                       </tr>
                   </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box-footer">


        </div>
    </div>

</section>
</div>
<script type="application/javascript">
        function deleteuser() {
            let id = $("input:radio:checked").val();
                if (id){
                    if (confirm("确认删除")){
                        $.ajax({
                            url:"/user/"+id,
                            type:"delete",
                            success:function (retdata) {
                                if(retdata=="ok"){
                                    alert("删除成功");
                                    window.location.reload();
                                }
                            },
                            error:function (retdata) {
                                alert("网络异常...")
                            }

                        })
                    }
                }
        }
</script>
</body>

</html>